import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:travel/screen/flutter_screenutil.dart';
import 'package:travel/utils/colors.dart';
import 'package:travel/utils/radian.dart';
import 'package:travel/utils/styles.dart';
import 'package:travel/utils/tools.dart';

class PasswordController extends GetxController {
  RxString password = ''.obs;
}

class PasswordView extends GetView<PasswordController> {
  const PasswordView({super.key});

  @override
  Widget build(BuildContext context) {
    return Obx(() => Scaffold(
          backgroundColor: ColorsUtils.backgroundColor,
          appBar: AppBar(
            automaticallyImplyLeading: true,
            leading: InkWell(
              onTap: () {
                Get.back();
              },
              child: Icon(
                Icons.arrow_back_ios,
                color: ColorsUtils.parseColorFromHexString(ColorsUtils.color3333),
                size: 20.w,
              ),
            ),
            leadingWidth: 40.w,
          ),
          body: SingleChildScrollView(
            padding: EdgeInsets.all(20.w),
            child: Column(
              children: [
                Container(
                  alignment: Alignment.centerLeft,
                  child: Text(
                    '设置新密码',
                    style:
                        StylesUtils.customTextStyle(color: ColorsUtils.color0000, fontSize: 32.sp),
                  ),
                ),
                Container(
                  padding: EdgeInsets.only(top: 10.h),
                  alignment: Alignment.centerLeft,
                  child: Text(
                    '密码只限8-20位的数字、字母和符号的组合，不支持空格。',
                    style: StylesUtils.customTextStyle(
                        color: ColorsUtils.color9999, fontSize: 13.sp, lineHeight: 1.2.h),
                  ),
                ),
                Container(
                    padding: EdgeInsets.only(top: 30.h, bottom: 25.h),
                    child: Container(
                      padding: EdgeInsets.only(right: 10.w),
                      child: TextField(
                        controller: ToolsUtils.editingController(controller.password.value),
                        cursorWidth: 2.0,
                        cursorRadius: const Radius.circular(2),
                        keyboardType: TextInputType.visiblePassword,
                        cursorColor: ColorsUtils.parseColorFromHexString(ColorsUtils.color3333),
                        style: StylesUtils.customTextStyle(
                            fontSize: 15.sp, color: ColorsUtils.color3333),
                        decoration: InputDecoration(
                          border: OutlineInputBorder(
                            borderRadius: BorderRadius.circular(15),
                            borderSide: BorderSide.none,
                          ),
                          focusedBorder: OutlineInputBorder(
                            borderRadius: BorderRadius.circular(15),
                            borderSide: BorderSide.none,
                          ),
                          hintText: '请输入密码',
                          contentPadding: EdgeInsets.symmetric(vertical: 10.h, horizontal: 10.w),
                          isCollapsed: true,
                          isDense: true,
                          fillColor: ColorsUtils.parseColorFromHexString(ColorsUtils.colorF8f8),
                          filled: true,
                          hintStyle: StylesUtils.customTextStyle(
                              color: ColorsUtils.color9999, fontSize: 15.sp),
                        ),
                        onChanged: (String keyword) {
                          controller.password.value = keyword;
                        },
                      ),
                    )),
                Center(
                  child: Container(
                    width: 345.w,
                    height: 45.h,
                    alignment: Alignment.center,
                    decoration: const BoxDecoration(color: Colors.white),
                    child: InkWell(
                      onTap: () {},
                      child: Container(
                        decoration: BoxDecoration(
                            borderRadius: BorderRadius.circular(10.w),
                            gradient: LinearGradient(colors: [
                              ColorsUtils.rgba(52, 120, 246, 1),
                              ColorsUtils.rgba(2, 167, 240, 1)
                            ], stops: const [
                              0,
                              0.99
                            ], transform: GradientRotation(RadianUtils.angleToRadian(90)))),
                        alignment: Alignment.center,
                        child: Text(
                          '确定',
                          style: StylesUtils.customTextStyle(fontSize: 16.sp),
                        ),
                      ),
                    ),
                  ),
                ),
              ],
            ),
          ),
        ));
  }
}
